package com.qf.web.servlet;

import com.alibaba.fastjson.JSON;
import com.qf.domain.GoodsType;
import com.qf.sevice.GoodsTypeService;
import com.qf.sevice.Impl.GoodsTypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * projectName:Shopping
 * author:RongChao
 * time:2022/4/19 17:23
 * description:
 */
@WebServlet("/goodstypeservlet")
public class GoodsTypeServlet extends BaseServlet {
    GoodsTypeService goodsTypeService = new GoodsTypeServiceImpl();
    public void goodstypelist(HttpServletRequest request, HttpServletResponse response) throws Exception{
        List<GoodsType> goodsTypes  = goodsTypeService.findTypeListByLevel(1);
        Object json = com.alibaba.fastjson.JSON.toJSON(goodsTypes);
        response.setCharacterEncoding("UTF-8");
        response.getWriter().print(json);
    }

}
